package com.guigu.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guigu.pojo.OrdersParticulars;
import com.guigu.service.OrdersParticularsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@CrossOrigin
@RestController
public class OrdersParticularsController {

    @Autowired
    OrdersParticularsService ordersParticularsService;

    @GetMapping("queryOrdersParticulars.action")
    public Page<OrdersParticulars> queryOrdersParticulars (OrdersParticulars ordersParticulars,
                                                           @RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
                                                           @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize
                                                           ){
        return ordersParticularsService.queryOrdersParticulars(ordersParticulars,pageno,pagesize);
    }

    @GetMapping("queryAllOrdersParticularsreturn.action")
    public Page<OrdersParticulars> queryOrdersParticularsreturn(Integer loginUserId,OrdersParticulars ordersParticulars,
                                                                @RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
                                                                @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize){
        return ordersParticularsService.queryOrdersParticularsreturn(loginUserId,ordersParticulars,pageno,pagesize);
    }

    //根据订单查看详情
    @GetMapping("queryDeatilById.action/{id}")
    public OrdersParticulars queryDeatilById(@PathVariable Integer id){
        return ordersParticularsService.queryDeatilById(id);
    }

    //未出货可直接退款
    @PostMapping("returnMoney.action")
    public Map returnMoneyById(@RequestBody OrdersParticulars detail){
        return ordersParticularsService.returnMoneyById(detail);
    }

    //退款前查询订单详情和订单信息
    @GetMapping("queryDeatilById2.action/{id}")
    public Map queryDeatilById2(@PathVariable Integer id){
        return ordersParticularsService.queryDeatilById2(id);
    }
}
